package sz.com.postoffice.jxyzwgcase.controller;

import com.alibaba.fastjson.JSONObject;
import com.huawei.ucmarket.security.permission.vo.UserInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import sz.com.postoffice.jxyzwgcase.pojo.SalesDepartment;
import sz.com.postoffice.jxyzwgcase.service.UserService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName UserContriller
 * @Deacription TODO
 * @Author 王盟
 * @Date 2020/10/23 13:58
 * @Version 1.0
 **/
@Api(value = "ADO集成打包部署测试微服务", tags = "{ ADO集成打包部署测试微服务 }")
@RestController
@Slf4j
@RequestMapping(value = "/tools")
public class UserController {

    @Resource
    private UserService userService;

    @ApiOperation(value = "获取ADO当前用户信息", notes = "获取ADO当前用户信息")
    @RequestMapping(value = "/userinfo", method = RequestMethod.GET)
    @ResponseBody
    public UserInfo getUserInfo() {
        UserInfo userInfo = userService.getUserInfo();
        return userInfo;
    }

    @ApiOperation(value = "获取ADO业务库数据", notes = "获取ADO业务库数据")
    @RequestMapping(value = "/salesList", method = RequestMethod.GET)
    @ResponseBody
    public List<SalesDepartment> findSalesList() {
        List<SalesDepartment> salesList = userService.getSalesList();
        return salesList;
    }

    @ApiOperation(value = "获取ADOToken", notes = "获取ADOToken")
    @RequestMapping(value = "/getToken", method = RequestMethod.POST)
    @ResponseBody
    public String getADOToken(@RequestBody JSONObject jsonObject) {
        return userService.getADOToken(jsonObject);
    }

    @ApiOperation(value = "同步用户adoId", notes = "同步用户adoId")
    @RequestMapping(value = "/getUserCode", method = RequestMethod.GET)
    @ResponseBody
    public void getUserCode(String empCode){
        userService.getUserList(empCode);
    }


}
